# Maintainer: Christian Rebischke <chris.rebischke@archlinux.org>
pkgname=ct
pkgver=0.9.4
pkgrel=1
pkgdesc='config transpiler for Flatcar Container Linux'
arch=('loong64' 'x86_64' 'aarch64')
url='https://github.com/flatcar/container-linux-config-transpiler'
license=('Apache')
depends=('kubectl')
makedepends=('git' 'go')
source=("${pkgname}-${pkgver}.tar.gz::https://github.com/flatcar/container-linux-config-transpiler/archive/refs/tags/v${pkgver}.tar.gz")
sha512sums=('a00e3a1ab401630a7c38a18b4f0ffb43d433134353e774ceae633338f32926989db75f18b2d58bcf7ed2103412472da8a8700990136c9197c0211680128edd75')
b2sums=('90d0c875d523e5223b1015fc2433c389f02437d129ac4cd683699a3d59fe50ec4465e7389cfd7f7636c233bf63b7091a35781fe1a54bbc4ce6fe62e867c00300')

build() {
  cd "container-linux-config-transpiler-${pkgver}/internal"
  export CGO_LDFLAGS="$LDFLAGS"
  export CGO_CFLAGS="$CFLAGS"
  export CGO_CPPFLAGS="$CPPFLAGS"
  export CGO_CXXFLAGS="$CXXFLAGS"
  export GOFLAGS='-buildmode=pie -trimpath -modcacherw -mod=readonly'
  go build -ldflags="-w -s -linkmode=external -X github.com/flatcar/container-linux-config-transpiler/internal/version.Raw=${pkgver}" -o ct
}

#check() {
#  cd "container-linux-config-transpiler-${pkgver}"
#  go test ./...
#}

package() {
  cd "container-linux-config-transpiler-${pkgver}/internal"
  install -Dm755 ct "${pkgdir}/usr/bin/ct"
}
